/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.h
  * @brief          : Header for main.c file.
  *                   This file contains the common defines of the application.
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2023 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under BSD 3-Clause license,
  * the "License"; You may not use this file except in compliance with the
  * License. You may obtain a copy of the License at:
  *                        opensource.org/licenses/BSD-3-Clause
  *
  ******************************************************************************
  */
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32h7xx_hal.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */

/* USER CODE END ET */

/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */

/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */

/* USER CODE END EM */

/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);

/* USER CODE BEGIN EFP */

/* USER CODE END EFP */

/* Private defines -----------------------------------------------------------*/
/* USER CODE BEGIN Private defines */
#define  LED_OFF       1
#define  LED_ON        0
#define  LED_FLICKER   2
 
#define LED_ERR_PORT    GPIOD
#define LED_RUN_PORT    GPIOD
#define LED_DIAG_PORT   GPIOD
#define LED_BKRUN_PORT  GPIOE   
#define LED_BKERR_PORT  GPIOE   

#define LED_ERR_PIN       GPIO_PIN_9
#define LED_RUN_PIN       GPIO_PIN_8
#define LED_DIAG_PIN     GPIO_PIN_10
#define LED_BKRUN_PIN    GPIO_PIN_14
#define LED_BKERR_PIN    GPIO_PIN_12

#define LED_ALL_ON()   do{ \
                            HAL_GPIO_WritePin(LED_RUN_PORT, LED_RUN_PIN, GPIO_PIN_SET); \
                            HAL_GPIO_WritePin(LED_ERR_PORT, LED_ERR_PIN, GPIO_PIN_SET); \
                            HAL_GPIO_WritePin(LED_DIAG_PORT, LED_DIAG_PIN, GPIO_PIN_SET); \
                            HAL_GPIO_WritePin(LED_BKRUN_PORT, LED_BKRUN_PIN, GPIO_PIN_SET); \
                            HAL_GPIO_WritePin(LED_BKERR_PORT, LED_BKERR_PIN, GPIO_PIN_SET); \
                        }while(0)

#define LED_ALL_OFF()   do{ \
                                HAL_GPIO_WritePin(LED_RUN_PORT, LED_RUN_PIN, GPIO_PIN_RESET); \
                                HAL_GPIO_WritePin(LED_ERR_PORT, LED_ERR_PIN, GPIO_PIN_RESET); \
                                HAL_GPIO_WritePin(LED_DIAG_PORT, LED_DIAG_PIN, GPIO_PIN_RESET); \
                                HAL_GPIO_WritePin(LED_BKRUN_PORT, LED_BKRUN_PIN, GPIO_PIN_RESET); \
                                HAL_GPIO_WritePin(LED_BKERR_PORT, LED_BKERR_PIN, GPIO_PIN_RESET); \
                                }while(0)       

                        
#define LED_ALL_FLICKER()   do{ \
                                    HAL_GPIO_TogglePin(LED_RUN_PORT, LED_RUN_PIN); \
                                    HAL_GPIO_TogglePin(LED_ERR_PORT, LED_ERR_PIN); \
                                    HAL_GPIO_TogglePin(LED_DIAG_PORT, LED_DIAG_PIN); \
                                    HAL_GPIO_TogglePin(LED_BKRUN_PORT, LED_BKRUN_PIN); \
                                    HAL_GPIO_TogglePin(LED_BKERR_PORT, LED_BKERR_PIN); \
                                }while(0)            
/* USER CODE END Private defines */

#ifdef __cplusplus
}
#endif

#endif /* __MAIN_H */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
